<!--main-container-part-->
<div id="content">
    <!--breadcrumbs-->
    <div id="content-header">
        <div id="breadcrumb">
            <a href="/backend/index.html" title="返回后台首页" class="tip-bottom"> <i class="icon-home"></i>
                后台首页
            </a>
            <a href="#" class="current">新闻管理</a>

        </div>
        <h1>新闻管理</h1>
    </div>

    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">

                <div class="widget-box">
                    <div class="widget-title">
                        <span class="icon">
                            <input type="checkbox" name="checkbox" id="selectAll" />
                        </span>
                        <h5>新闻列表</h5>
                    </div>
                    <div class="widget-content nopadding">
                    <form action="__CONTROLLER__/deleteBatch" method="POST" id='delform'>
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th> <i class="icon-resize-vertical"></i>
                                    </th>
                                    <th>编号</th>
                                    <th>分类</th>
                                    <th>标题</th>
                                    <th>时间</th>
                                    <th>点击量</th>

                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>

                               <volist name="news" id="vo">
                                    <tr>
                                        <td>
                                            <input type="checkbox" name="aid[]" value="{$vo.aid}" class="selectCheckbox" />
                                        </td>
                                        <td>{$vo.aid}</td>
                                        <td>{$vo.cateid}</td>
                                        <td>{$vo.title}</td>
                                        <td>{$vo.time|date='Y-m-d H:i:s',###}</td>
                                        <td>{$vo.click}</td>
                                        <td>
                                            <a href="__CONTROLLER__/edit/aid/{$vo.aid}" class="btn btn-primary btn-mini">修改</a>
                                            <a href="__CONTROLLER__/delete/aid/{$vo.aid}" onclick="return confirm('确定删除该条新闻?')" class="btn btn-danger btn-mini">删除</a>
                                            <a href="__CONTROLLER__/show/aid/{$vo.aid}" class="btn btn-success btn-mini">预览</a>
<!--                                             <a href="__CONTROLLER__/show/aid/{$vo.aid}" class="btn btn-warning btn-mini">隐藏</a> -->
                                        </td>
                                    </tr>
                                </volist>

                                <tr>
                                    <td colspan="9">
                                        <a class="btn btn-primary btn-mini" href="__CONTROLLER__/add">添加新闻</a>
                                        <a class="btn btn-primary btn-mini deleteAll" >批量删除</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        </form>
                    </div>
                </div>
                <!-- page start -->
                <div class="pagination" style="text-align: center;">
                    <ul>
                        {$page}
                    </ul>
                </div>
                <!-- page end -->
            </div>
        </div>
        <!-- search begin -->
        <hr>
        <div class="row-fluid">
            <div class="span12 search">
                <input type="text" name="title" id="title" class="span3" placeholder="请输标题关键字">
                <button type="button" class="btn btn-primary" id="searchBut">搜索</button>
            </div>
        </div>
        <!-- search end -->
    </div>
    <!--End-breadcrumbs-->
</div>

<!--end-main-container-part-->
<script type="text/javascript">
var selectStr = '';
$(function(){
    //赋值全部复选框
    $('#selectAll').click(function(){
            if($('#selectAll').attr('checked') == 'checked'){
                $('.selectCheckbox').attr('checked', 'checked');
            }else{
                $('.selectCheckbox').removeAttr('checked');
                selectStr = '';
            }
        }
    )

    //赋值单个复选框
    $('selectCheckbox').click(
        function(){
            if ($(this).attr('checked')=='checked') {
                $('selectCheckbox').removeAttr('checked');
            }else{
                $('selectCheckbox').attr('checked','checked');
            }
        }
    )

    //批量删除按钮
    $('.deleteAll').click(
        function(){
            if ($('.selectCheckbox').attr('checked')==='undefined') {
                alert('请选择要删除的新闻');
            }else{
                if (confirm("确定删除选中的新闻？")==true) {
                    $('#delform').click().submit();
                }else{
                    return false;
                }
            }
        }
    );

    //搜索按钮
    $('#searchBut').click(function(){
            window.location.href="__CONTROLLER__/showlist/keywords/"+$('#title').val();
        }
    );

});


//添加回车键搜索
$(document).keydown(function (event) {
    if(event.keyCode ==13){
       if ($('#title').val()=='') {
            alert("请输入搜索内容");
       }else{
            window.location.href="__CONTROLLER__/showlist/keywords/"+$("#title").val();
       }
    }
});
//回车键搜索结束

</script>